package com.da.landlord;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Index;

import com.googlecode.cswish.annotation.cm;
import com.ra.landlord.LandlordOwner;
import com.ra.landlord.LandlordOwnerUser;
import com.ra.landlord.LandlordUser;

/**
 * 抄表
 * @author Peter.Z
 *
 */
@Entity
@Table(name="da_dameter")
public class DaMeter implements LandlordOwner{
	
	private Integer id;
	
	@cm("当前刻度")
	private BigDecimal count;
	
	@cm("单价")
	private BigDecimal  price;
	
	@cm("抄表时间")
	private Date checkTime;
	
	@cm("计费规则")
	private DaFeeRule feeRule;
	
	//Transient
	@cm("是否可被删除")
	private Boolean deletable;

	@cm("抄表员")
	private LandlordUser reader;
	
	@cm("房东")
	private LandlordOwnerUser landlordUser;
	
	//有一个人type来确定抄送是电表，还是水表
	//cfg 同样是有一个type确是否为抄表配置 有一类型来确定电表还是水表。才能得到具体的单价。
	//每一个费用产生一个item 指向一个房间。 
	
	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public BigDecimal getCount() {
		return count;
	}

	public void setCount(BigDecimal count) {
		this.count = count;
	}

	public BigDecimal getPrice() {
		return price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public Date getCheckTime() {
		return checkTime;
	}

	public void setCheckTime(Date checkTime) {
		this.checkTime = checkTime;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@Index(name="idx_ra_daMeter_feeRule_id")
	public DaFeeRule getFeeRule() {
		return feeRule;
	}

	public void setFeeRule(DaFeeRule feeRule) {
		this.feeRule = feeRule;
	}

	@Transient
	public Boolean getDeletable() {
		return deletable;
	}

	public void setDeletable(Boolean deletable) {
		this.deletable = deletable;
	}

	@ManyToOne
	public LandlordUser getReader() {
		return reader;
	}

	public void setReader(LandlordUser reader) {
		this.reader = reader;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@Override
	public LandlordOwnerUser getLandlordUser() {
		return landlordUser;
	}

	@Override
	public void setLandlordUser(LandlordOwnerUser landlordUser) {
		this.landlordUser = landlordUser;
	}
}
